from selenium.webdriver.common.by import By
from common.Utils import ForumDriver

class ForumMyPost:
    url=""
    driver=""
    def __init__(self):
        self.url="http://127.0.0.1:9580/index.html"
        self.driver=ForumDriver.driver
        self.driver.get(self.url)
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_avatar").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_user_profile").click()

    #我的帖子界面测试
    def MyPost(self):
        # 验证界面信息
        # 用户头像、用户名、发帖数、邮箱、注册日期和个人介绍
        self.driver.find_element(By.CSS_SELECTOR,"#profile_avatar")
        self.driver.find_element(By.CSS_SELECTOR,"#profile_nickname")
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col > div > div:nth-child(1)")
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col > div > div:nth-child(2)")
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col > div > div:nth-child(3)")
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-body > div > div > div.col-lg-4 > div > div > div > div")
        #验证第一条帖子的信息：标题、发布时间、浏览量、点赞数、评论数
        self.driver.find_element(By.CSS_SELECTOR,"#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-truncate")
        self.driver.find_element(By.CSS_SELECTOR,"#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-muted.mt-2 > div > div.col > ul > li")
        self.driver.find_element(By.CSS_SELECTOR,"#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-muted.mt-2 > div > div.col-auto.d-none.d-md-inline > ul > li:nth-child(1)")
        self.driver.find_element(By.CSS_SELECTOR,"#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-muted.mt-2 > div > div.col-auto.d-none.d-md-inline > ul > li:nth-child(2)")
        self.driver.find_element(By.CSS_SELECTOR,"#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-muted.mt-2 > div > div.col-auto.d-none.d-md-inline > ul > li:nth-child(3)")
        # 截图验证
        ForumDriver.getScreeShot()

        #点击第一条帖子 验证用户名、用户头像、点赞和回复按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR,"#profile_article_body > li:nth-child(1) > div.card.timeline-event-card > div > div > div > div > div.text-truncate > a > strong").click()
        self.driver.find_element(By.CSS_SELECTOR,"#article_details_author_avatar")
        self.driver.find_element(By.CSS_SELECTOR,"#article_details_author_name")
        self.driver.find_element(By.CSS_SELECTOR,"#details_btn_like_count")
        self.driver.find_element(By.CSS_SELECTOR,"#details_btn_article_reply")
        # 截图验证
        ForumDriver.getScreeShot()

#创建post类对象
# post = ForumMyPost()
# # 我的帖子界面测试
# post.MyPost()




